import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {Contract} from '../../types/resp/Contract';

@Component({
  selector: 'contract-view',
  imports: [
    SharedModule
  ],
  templateUrl: './contract-view.component.html',
  standalone: true
})
export class ContractViewComponent implements OnInit {
  contractForm!: FormGroup;
  isVisible: boolean = false
  title: string = '劳动合同信息详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.contractForm = this.fb.group({
      employeeName: [''],
      contractSignDate: [''],
      contractType: [undefined],
      effectiveDate: [''],
      expiryDate: [''],
      state: [undefined],
      workLocation: [''],
      workingHours: [''],
      jobDescription: [''],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(contract: Contract) {
    this.isVisible = true
    this.contractForm.patchValue(contract);
    this.contractForm.disable();
  }
}
